package day06;

import java.util.Arrays;
import java.util.Scanner;

//方法的演示
public class MethodDemo {

    //嵌套调用
    public static void aMethod(){
        System.out.println("111");
        bMethod();
        System.out.println("222");
    }
    public static void bMethod(){
        System.out.println("333");
    }














/*
    //扩展联系
    public static int[] testArray(int len, int max) {
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * (max + 1));
        }
        return arr;
    }

 */


    //排序
    public static void sort() {


        Arrays.sort(testArray());


    }


    //调用testArray中数组并输出
    public static void out() {
        for (int i = 0; i < testArray().length; i++) {
            System.out.println(testArray()[i]);
        }
    }

    //无参有返回值
    public static int[] testArray() {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);

        }
        return arr;
    }

    //有参有返回值
    public static int plus(int num1, int num2) {
        int sum = num1 + num2;

        return sum;
    }


    //无参有返回值
    public static boolean gettf() {
        if (2 > 1) {
            return true;
        } else {
            return false;
        }
    }


    //无参有返回值
    public static double getNum() {


        return 2.0; //1)结束方法的执行   2）返回结果给调用方
    }


    //有参无返回值
    public static void sayHello(String name, int age) {
        if (age > 60) {
            return;
        }
        System.out.println("大家好我叫" + name + "，今年我" + age + "岁了");
    }


    //有参无返回值
    public static void sayHi(String name) {
        System.out.println("大家好，我叫" + name + "，今年39岁了");

    }


    //无参无返回值
    //想谁问好，就谁问好
    public static void say() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("大家好，我叫Jones，今年23岁了");
    }


    public static void main(String[] args) {




        aMethod();
        System.out.println(" ");
        say();
        say();
        say();
        System.out.println("继续执行........");

        sayHi("WKJ");


        sayHello("张三", 25);
        sayHello("李四", 30);
        sayHello("王五", 88);

        double a = getNum();
        System.out.println(a);
        System.out.println(getNum() + "," + getNum());

        System.out.println(gettf());

        int num1 = (int) (Math.random() * 100 + 1);
        int num2 = (int) (Math.random() * 100 + 1);
        System.out.println(num1 + "," + num2);

        System.out.println("num1+num2= " + plus(num1, num2));


        int[] d = testArray();
        System.out.println(d[0]);

        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        sort();
        out();

        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");
        System.out.println(" ");

/*
        int[] dd = testArray(10, 100);//模拟第一个人访问
        System.out.println("数组的长度为" + d.length);
        for (int i = 0; i < d.length; i++) {
            System.out.println(d[i]);
        }

        int[] e = testArray(5, 50);//模拟第二个人访问
        System.out.println("数组的长度为" + e.length);
        for (int i = 0; i < e.length; i++) {
            System.out.println(e[i]);
        }

 */

        /*
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入两个数");
        System.out.println("请输入第一个数");
        num1 = scanner.nextInt();
        System.out.println("请输入第二个数");
        num2 = scanner.nextInt();
        int sum = plus(num1, num2);
        System.out.println("两数之和=" + sum);


*/



    }
}

